package com.el.config;

import com.el.bean.Person;
import com.el.service.BookService;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * 配置类==配置文件
 * 作用：告诉Spring该类是个配置类
 */
@Configuration

@ComponentScans(
        value = {
                @ComponentScan(value="com.el",includeFilters={
                      /*  @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class}),
                        @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE,classes = {BookService.class}),*/
                        @ComponentScan.Filter(type=FilterType.CUSTOM,classes = {MyTyptFilter.class})
                },useDefaultFilters = false)
        }
)
//@ComponentScan:指定扫描的包
//excludeFilters=Filter[]:指定扫描时按照什么规则排除哪些组件
//includeFilters=Filter[]:指定扫描时包含哪些组件
//type = FilterType.ANNOTATION:按照注解
//type=FilterType.ASSIGNABLE_TYPE:按照给定的类型
//type=FilterType.ASPECTJ:使用ASPECTJ表达式
//type=FilterType.REGEX:使用正则
//type=FilterType.CUSTOM:使用自定义
public class Config {
    /*
    给容器中注册一个bean，类型为返回值的类型，id默认为方法名
       @Bean("person")：可以修改默认id
     */
    @Bean("person")
    public Person person1(){
        Person person = new Person("李四", 12, 1);
        return person;
    }
}
